/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#ifndef SX_GRAPHICS_CONTEXT_H
#define SX_GRAPHICS_CONTEXT_H

#include <sxColor3.h>
#include <sxColor4.h>

namespace Sx {
namespace Graphics {

/*
 * Various graphics libraries maintain different representations. OpenGL
 * provides an internal state machine and DirectX maintains a pointer to
 * a direct3d device. The GraphicsContext class is used to store any informaiton
 * that relates to establishing a graphics device for an application. Typically
 * there will only be one GraphicsContext instance per-application (usually
 * OpenGL and DirectX are not both utilized during runtime).
 *
 * Setup of the context should be done within the implementation of the
 * initialize function. To teardown the context, the destructor should be used.
 * The GraphicsContext class provides two functions that provide initial and
 * final operations for rendering a frame: preRender() and postRender().
 * Objects and buffered geometric type should be rendered inbetween these two
 * function calls.
 *
 * Note that a graphics context does not provide any information about a
 * specific viewport nor does it provide any behavior related to the user
 * interface of an application.
 *
 * (TLDR) Graphics context represents the state of a graphics library/device,
 * and typically stores a reference to any allocated resources or settings used 
 * by the library/device.
 */
class GraphicsContext {
public:
	GraphicsContext();
	virtual ~GraphicsContext();

	/* 
	 * Function used to setup a graphics library context. This may indicate
	 * setting initial parameters or creating access to a rendering device.
	 */
	virtual bool initialize() = 0;

	/* 
	 * Function called before wold/scene geometry should be rendered. Typically
	 * this will consist of a clear function used to clear the frame buffer.
	 */
	virtual bool preRender() const = 0;

	/* 
	 *Function called after world/scene geometric objects have been rendered.
	 * Typically this is a present call (DirectX) or a swap buffers (OpenGL).
	 */
	virtual bool postRender() const = 0;

	/* 
	 * Returns true if this context has been initialized. The implementation
	 * of the initialize function should set this flag once the context has
	 * been properly contructed.
	 */
	bool isInitialized() const;

protected:
	bool initialized;
};

}

}

#endif
